package com.forezp.thinking.chapter14.dynamicproxy;

import com.forezp.thinking.chapter14.proxy.Interface;
import com.forezp.thinking.chapter14.proxy.RealObject;

import java.lang.reflect.Proxy;

/**
 * Created by forezp on 2017/12/4.
 */
public class Test {

    public static void consume(Interface i) {
        i.doSomething();
        i.doSomethingElse("xs");
    }

    public static void main(String[] args) {

        RealObject realObject = new RealObject();
        Interface i= (Interface) Proxy.newProxyInstance(realObject.getClass().getClassLoader(),
                realObject.getClass().getInterfaces(),new DynamicProxyHandler(realObject));
        consume(i);
    }
}
